//
//  DynaModel.m
//  u76ho
//
//  Created by m-air-01 on 16/1/28.
//  Copyright © 2016年 LV. All rights reserved.
//

#import "DynaModel.h"

@implementation DynaModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        if ([key isEqualToString:@"errmsg"]) {
            NSArray * arr = value;
            NSMutableArray * mArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<arr.count; i++) {
                NSDictionary * dic = arr[i];
                DynaOneModel * model = [[DynaOneModel alloc]initDic:dic];
                [mArr addObject:model];
            }
            _dynaArr = mArr;
        }
        else
        {
            [super setValue:value forKey:key];
        }
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}
@end

//*********************************************
@implementation DynaOneModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        if ([key isEqualToString:@"a"]) {
            NSArray * arr = value;
            NSDictionary * dic = arr.firstObject;
            DynaBaseinfoModel * model = [[DynaBaseinfoModel alloc]initDic:dic];
            _baseInfomodel = model;
        }
        
        if ([key isEqualToString:@"b"]) {
            NSArray * arr = value;
            NSMutableArray * mArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<arr.count; i++) {
                NSDictionary * dic = arr[i];
                DynaCommendModel * model = [[DynaCommendModel alloc]initDic:dic];
                [mArr addObject:model];
            }
            _dynaCommendmodelArr = mArr;
        }
        
        if ([key isEqualToString:@"c"]) {
            NSArray * arr = value;
            NSMutableArray * mArr = [[NSMutableArray alloc]init];
            for (int i = 0; i<arr.count; i++) {
                NSDictionary * dic = arr[i];
                DynaZanModel * model = [[DynaZanModel alloc]initDic:dic];
                [mArr addObject:model];
            }
            _dynaZanmodelArr = mArr;
        }
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end

//*********************************************
@implementation DynaBaseinfoModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end

//*********************************************
@implementation DynaCommendModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [super setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}
@end

//*********************************************
@implementation DynaZanModel

-(instancetype)initDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if (value) {
        [super setValue:value forKey:key];
    }
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    NSLog(@"key = %@",key);
}

@end
